$(function () {
  $('.del').click(function (e) {
  	console.log("e:"+e)
    var target = $(e.target),
      id = target.data('id'),
      tr = $('.item-id-' + id);
      console.log('id:'+id+'  tr:'+tr)
    $.ajax({
        type: 'delete',
        url: '/admin/movie/list?id=' + id
      })
      .done(function (results) {
        if (results.success === 1) {
          if (tr.length > 0) {
            tr.remove()
          }
        }
      })
  })

  $('#douban').blur(function(){//id为douban的input失去焦点的时候，触发事件
    var douban=$(this)
    var id=douban.val()

    $.ajax({
      url:'https://api.douban.com/v2/movie/subject/'+id,
      cache:true,
      type:'get',
      dataType:'jsonp',
      crossDomain:true,
      jsonp:'callback',
      success:function(data){
        $('#inputTitle').val(data.title)
        $('#inputDoctor').val(data.directors[0].name)
        $('#inputCountry').val(data.countries[0])
        $('#inputPoster').val(data.images.large)
        $('#inputYear').val(data.year)
        $('#inputSummary').val(data.summary)
      }

    })
  })

})
